﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace BPM.Base.WFLib.CustomerAttribute
{
    public partial class CheckBoxSelector : Control
    {
        public CheckBoxSelector()
        {
            InitializeComponent();
        }
        /// <summary> 
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        

        private void InitializeComponent()
        {
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnOK = new System.Windows.Forms.Button();
            this.panel1 = new System.Windows.Forms.Panel();
            this.SuspendLayout();
            // 
            // btnCancel
            // 
            this.btnCancel.Location = new System.Drawing.Point(0, 22);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(20, 20);
            this.btnCancel.TabIndex = 0;
            this.btnCancel.Text = "×";
            this.btnCancel.UseVisualStyleBackColor = true;
            // 
            // btnOK
            // 
            this.btnOK.Location = new System.Drawing.Point(-1, 0);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(20, 20);
            this.btnOK.TabIndex = 1;
            this.btnOK.Text = "√";
            this.btnOK.UseVisualStyleBackColor = true;
            // 
            // panel1
            // 
            this.panel1.AutoScroll = true;
            this.panel1.Location = new System.Drawing.Point(23, 3);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(104, 100);
            this.panel1.TabIndex = 2;
            // 
            // UserControl1
            // 
            //this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.btnOK);
            this.Controls.Add(this.btnCancel);
            this.Name = "UserControl1";
            this.Size = new System.Drawing.Size(131, 107);

            btnOK.Click += new EventHandler(btnOK_Click);
            btnCancel.Click += new EventHandler(btnCancel_Click);
            this.ResumeLayout(false);

        }

        

        void btnCancel_Click(object sender, EventArgs e)
        {
            value = "";
            
        }

        void btnOK_Click(object sender, EventArgs e)
        {
            string s = "";

            foreach (Control c in panel1.Controls)
            {
                CheckBox obj = c as CheckBox;

                if (obj != null)
                {
                    if (obj.Checked)
                    {
                        s = s + obj.Text + split;
                    }
                }
            }

            if (s == "")
            {
               value="";
            }
            else
            {
                value = s.Remove(s.Length - 1);
            }//

            
        }


       
       
        public  System.Windows.Forms.Button btnCancel;
        public  System.Windows.Forms.Button btnOK;
        private System.Windows.Forms.Panel panel1;


        public string value
        {
            get;
            set;

        }


        private List<string> _list=new List<string>();

        public List<string> list
        {
            get { return _list; }
        }

        private string _split=",";

        public string split
        {
            set { _split  = value; }
            get { return _split ; }
        }


        public void FillPanel()
        {
            int top = 0;

            this.panel1.Controls.Clear();
            foreach(string item in list)
            {

              CheckBox cb = new CheckBox();
              
              cb.Text = item;
              cb.Top =top;
             
           
              panel1.Controls.Add(cb);
              top = top + 20;
            }
            
        }

   
        
        


    }
}
